草庐IT

Python NotImplemented 常量

全部标签

ruby - 我可以使用 rspec 模拟来 stub 版本常量吗?

我的代码只需要在特定版本的ActiveRecord上运行(解决旧AR库上的错误的方法)。此代码测试ActiveRecord::VERSION常量的值以查看它是否需要运行。有没有办法在rspec中模拟这些常量,这样我就可以测试该代码路径,而无需在测试机器上安装正确的ActiveRecordgem? 最佳答案 我最终编写了一个辅助方法来让我在执行代码块时覆盖常量:defwith_constants(constants,&block)constants.eachdo|constant,val|Object.const_set(consta

ruby-on-rails - 未初始化常量 RSpec::Core::ExampleGroup::Nested_1::Factory

我使用rspec-guard连续运行我的测试,但有时测试失败是因为:Running:spec/requests/signup_spec.rbFFFailures:1)SignupdoesnotemailconfirmationmailaftersignupFailure/Error:visitnew_user_pathNameError:undefinedlocalvariableormethod`new_user_path'for##./spec/requests/signup_spec.rb:4:in`block(2levels)in'2)Signupshouldemailconf

ruby-on-rails - DBI::InterfaceError:无法加载驱动程序(未初始化常量 MysqlError)

我已经包含了gem,dbd-mysql(0.4.4)dbi(0.4.5)mysql(2.8.1)当我运行以下代码时在Rails控制台上,require'rubygems'require"dbi"require'dbd-mysql'dbh=DBI.connect("DBI:Mysql:TestDB:localhost","username","pwd")1.9.2-p180:001>require'rubygems'=>false1.9.2-p180:002>require"dbi"=>false1.9.2p180:003>require'dbd-mysql'LoadError:nosu

ruby - NameError(未初始化常量 ActionDispatch::ExceptionWrapper):

无论我在我的应用程序中遇到什么错误,我都无法在我的日志中看到错误,我得到以下信息关于我面临的所有错误的消息,所以我无法解决我的错误,有人能帮我解决这个问题吗??Completed500InternalServerErrorin729msNameError(uninitializedconstantActionDispatch::ExceptionWrapper):Rendered/usr/share/ruby-rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/r

ruby-on-rails - Rails 未初始化常量 ActiveSupport::Autoload (NameError)?

我在看MichaelHartl教程的第3章,我卡在了测试部分。最初它有一个未初始化的常量Rails(NameError)的问题,但是在添加之后require'rspec/rails'require'active_support'require'active_support/deprecation'require'activerecord-nulldb-adapter'在spec_helper.rb文件中,存在未初始化常量ActiveSupport::Autoload(NameError)的新问题。附上错误:C:\Users\HuiHui\MyProject\sampleapp>bund

ruby-on-rails - 事件管理路由错误未初始化常量 Admin::DashboardController

更新ActiveAdmin后出现以下错误:http://0.0.0.0:3000/adminRoutingErroruninitializedconstantAdmin::DashboardController我尝试在ActiveActive路由之前移动我的自定义根目录和设计路由。我的路线:MyApp::Application.routes.drawdoroot:to=>"download#index"devise_for:users,ActiveAdmin::Devise.configActiveAdmin.routes(self)我的佣金路线:root/download#index

ruby-on-rails - "db:migrate rake aborted"错误由于未初始化常量 Rake::FileUtilsExt

我是RubyonRails的新手,我一直在尝试部署一个简单的Cappuccino在过去的三天里,使用RubyonRails的应用程序在Heroku上运行,每次我初始化(herokurakedb:migrate)时,我都会收到以下错误。(in/app)rakeaborted!uninitializedconstantRake::FileUtilsExt/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2482:in`const_missing'/app/Rakefile:15:in`'/app/Rakefile:14:in`'/usr/ruby1.9.2/lib

ruby - 如何使模块常量在特征类中也可见?

我创建了一个包含常量NAME的模块和一种方法hello.如果一个类包含模块,则两个定义应该在不同范围内可见。moduleANAME='Otto'defself.included(base)base.extend(ClassMethods)enddefhello(name='world')self.class.hello(name)endmoduleClassMethodsdefhello(name='world')"Hello#{name}!"endendendclassBincludeAdefinstance_scopep[__method__,hello(NAME)]enddefs

ruby - Minitest未初始化常量错误

我正在尝试使用raketest和Spec语法运行Minitest并得到这个错误:/path/to/gem/spec/script_spec.rb:3:in`':uninitializedconstantMyGem(NameError)我的Rakefile:require'rake/testtask'Rake::TestTask.newdo|t|t.test_files=FileList['spec/*_spec.rb']end我的文件结构:gem/--lib/----script.rb--spec/----script_spec.rb--Rakefile我的脚本.rb:moduleMy

ruby-on-rails - 运行 Rails 控制台时未初始化的常量测试

在终端中运行railsconsole时,我得到了uninitializedconstantTest。我不确定为什么我只是设置它并使用命令railsserver工作。这是我得到的错误:/usr/lib/ruby/vendor_ruby/active_support/test_case.rb:12:in`':uninitializedconstantTest(NameError) 最佳答案 我在我的Ubuntu14.04桌面上遇到了同样的问题。通过以下方式解决:sudoapt-get安装ruby​​-test-unitechorequi